package com.chenxu.gmall.mapper;

import com.chenxu.gmall.bean.KeywordStats;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Date: 2021/07/20
 * Desc: 关键词统计Mapper
 */
public interface KeywordStatsMapper {

    //keyword_stats_0709.ct * " +
    //        "multiIf(source='SEARCH',10,source='ORDER',3,source='CART',2,source='CLICK',1,0)就是对应打分；
    @Select("select keyword," +
        "sum(keyword_stats_0709.ct * " +
        "multiIf(source='SEARCH',10,source='ORDER',3,source='CART',2,source='CLICK',1,0)) ct" +
        " from keyword_stats_0709 where toYYYYMMDD(stt)=#{date} group by keyword " +
        "order by sum(keyword_stats_0709.ct) asc limit #{limit} ")
    public List<KeywordStats> selectKeywordStats(@Param("date") int date, @Param("limit") int limit);
}

